package com.asset.dispoal.gbEvidenceIdentification;

import com.asset.dispoal.gbEvidenceIdentification.api.GbEvidenceIdentificationService;
import com.asset.dispoal.gbEvidenceIdentification.dto.GbEvidenceIdentificationRequest;
import com.asset.dispoal.gbEvidenceIdentification.dto.GbEvidenceIdentificationResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.mhuang.pacebox.springboot.core.controller.BaseController;
import tech.mhuang.pacebox.springboot.core.permission.annotation.Permission;
import tech.mhuang.pacebox.springboot.protocol.Result;
import tech.mhuang.pacebox.springboot.protocol.data.PageVO;

import java.util.List;

/**
 * 识别通用配置控制层
 *
 * @author: mhuang
 * @date: 2022-03-03 13:51:16
 */
@RestController
@RequestMapping("gb/evidenceIdentification")
@Api(value = "证据识别管理", tags = "证据识别管理")
public class GbEvidenceIdentificationController extends BaseController {

    @Autowired
    private GbEvidenceIdentificationService gbEvidenceIdentificationService;

    @Permission(code = "generalEvidenceDistinguish", param = "create_user")
    @GetMapping(value = "/page")
    @ApiOperation(value = "分页查询", notes = "分页查询")
    public Result<PageVO<GbEvidenceIdentificationResponse>> page(GbEvidenceIdentificationRequest request) {
        return gbEvidenceIdentificationService.queryPage(request);
    }

    @Permission(code = "generalEvidenceDistinguish:add")
    @PostMapping(value = "/insert")
    @ApiOperation(value = "添加", notes = "添加")
    public Result insert(@RequestBody List<GbEvidenceIdentificationRequest> request) {
        gbEvidenceIdentificationService.insert(request);
        return Result.ok();
    }

    @Permission(code = "generalEvidenceDistinguish:update")
    @PutMapping(value = "/update")
    @ApiOperation(value = "修改", notes = "修改")
    public Result update(@RequestBody GbEvidenceIdentificationRequest request) {
        gbEvidenceIdentificationService.update(request);
        return Result.ok();
    }

    @Permission(code = "generalEvidenceDistinguish:del")
    @PostMapping(value = "/delete")
    @ApiOperation(value = "删除", notes = "删除")
    public Result delete(@RequestBody String id) {
        gbEvidenceIdentificationService.delete(id);
        return Result.ok();
    }


}